#include "ItemBlockEntity.h"




ItemBlockEntity::ItemBlockEntity(int id, int itemType, double x, double y)
{
	_data = new ItemData(id, itemType, x, y, GameDeviceSingleton::getInstance()->getPlayerRect());
	_stateInBlock = new ItemBlockStateInBlock(_data);
	_stateFired = new ItemBlockStateFired(_data);
	_state = _stateInBlock;
}

void ItemBlockEntity::update(long time)
{
	_state->udpate(time);
	checkState();
}

void ItemBlockEntity::draw(long time)
{
	_state->draw(time);
}

AbstractData* ItemBlockEntity::getAbstractData()
{
	return _data;
}

void ItemBlockEntity::initData()
{

}

void ItemBlockEntity::updateData(int action, int action_data)
{
	_state->updateData(action, action_data);
}

ItemData* ItemBlockEntity::getItemData()
{
	return _data;
}

void ItemBlockEntity::checkState()
{
	switch(_data->stateitem) {
	case StateBlock:
		_state = _stateInBlock; break;
	case StateFired:
		_state = _stateFired; break;
	}
}
